<template>
	<view class="con">
		<view class="title">当前位置</view>
		<view class="search">
			<image class="search_left" src="/static/1.png" mode=""></image>
			<view class="search_box">
				吉林 ·
				<span class="span">{{ cityStore.name }}</span>
			</view>
			<image class="search_right" src="/static/49.png" mode=""></image>
		</view>
		<view class="title">行政区域</view>

		<view class="list">
			<view
				class="list_nr"
				:class="cityStore.name == item.name ? 'list_nr_xz' : ''"
				v-for="(item, index) in list"
				:key="index"
				@click="list_clcik(item.name)">
				{{ item.name }}
			</view>
		</view>
	</view>
</template>

<script setup>
	import { useCityStore } from '@/utils/cityStore.js'
	const cityStore = useCityStore()
	const http = inject('$http')
	let list = ref([])
	const list_clcik = (val) => {
		cityStore.name = val
		uni.navigateBack()
	}

	onMounted(async () => {
		http.noAuthpost('/srapi/home/index').then((res) => {
			console.log('返回值', res.area)
			list.value = res.area
		})
	})
</script>

<style lang="scss">
	.con {
		padding: 60rpx 30rpx;
	}
	.title {
		font-size: 28rpx;
		font-weight: 700;
		color: #000000;
		margin-bottom: 30rpx;
	}

	.search {
		background: #ffffff;
		border-radius: 42rpx;
		padding: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 60rpx;
		.search_left {
			width: 24rpx;
			height: 24rpx;
			margin-right: 20rpx;
		}
		.search_box {
			flex: 1;
			font-size: 24rpx;
			font-weight: 700;
			color: #000000;
			.span {
				font-size: 24rpx;
				font-weight: 500;
				color: #787878;
			}
		}
		.search_right {
			width: 24rpx;
			height: 18rpx;
		}
	}

	.list {
		display: grid;
		grid-template-columns: 1fr 1fr 1fr 1fr;
		gap: 12px; /* 间距相等 */
		margin-bottom: 60rpx;
		.list_nr {
			height: 64rpx;
			background: #ffffff;
			border-radius: 32rpx;
			font-size: 24rpx;
			font-weight: 500;
			text-align: center;
			color: #000000;
			line-height: 64rpx;
		}
		.list_nr_xz {
			background: #2266f9;
			color: #ffffff;
		}
	}
</style>
